from core.support import set_cutscene
from core.item import Item
from core.action import Action

class Ebay(Item):
    def __init__(self):
        Item.__init__(self, "Ebay")    # do basic initialization for every item
        self.is_on = False
        self.cost = -100
        self.points = 1
        # build list of actions
        self.add_action(PutOn)
    
    
    def get_description(self):
        if self.is_on:
            return "Your collection sold for $100!"
        else:
            return "Sell your extensive bug collection on eBay"


# define actions for this item

class PutOn(Action):
    def __init__(self):
        Action.__init__(self, "put_on")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Earn Money"
    
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    def get_method(self):
        return "post"
    
    # enabled only if lamp is off.
    def is_enabled(self):
        if self.item.is_on:
            return False
        else:
            return True
    
    # turn lamp on and add cutscene
    def do_action(self,game,room,request):
        self.item.is_on = True
        set_cutscene("It sold")
        return

